package pers.qianyu.module.core.domain.image.enums;

import com.baomidou.mybatisplus.annotation.*;
import pers.qianyu.module.image.exception.*;

import java.util.*;

/**
 * @author mizzle rain
 * @date 2021-02-11 12:59
 */
public enum NoticeTypeEnum {
    LIKED("点赞", 1),
    COLLECTED("收藏", 2),
    COMMENT("评论", 3),
    ;
    private String value;
    @EnumValue
    private Integer code;

    NoticeTypeEnum(String value, Integer code) {
        this.value = value;
        this.code = code;
    }

    public static NoticeTypeEnum getEnum(Integer type) {
        if (Objects.isNull(type)) {
            return null;
        }
        for (NoticeTypeEnum noticeTypeEnum : NoticeTypeEnum.values()) {
            if (Objects.equals(type, noticeTypeEnum.getCode())) {
                return noticeTypeEnum;
            }
        }
        throw new ImageException(ImageErrorCodeEnum.INVALID_NOTICE_TYPE);
    }

    public String getValue() {
        return value;
    }

    public Integer getCode() {
        return code;
    }
}
